Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Powershell 3.0 compatibility fix #126

Merged
merged 2 commits into from
Sep 28, 2016
Merged

Powershell 3.0 compatibility fix #126

merged 2 commits into from
Sep 28, 2016

Conversation

headsphere
Copy link
Contributor

@headsphere headsphere commented Sep 21, 2016

Fixed issue #44 with conditional formatting code that was breaking in Powershell 3

Fixed problem with conditional formatting code that was breaking in Powershell 3
@headsphere headsphere changed the title Update Export-Excel.ps1 Powershell 3.0 compatibility fix Sep 21, 2016
@headsphere
Copy link
Contributor Author

Sorry, I haven't been able to run any of the unit tests. Please let me know if there are any problems with this!

@dfinke
Copy link
Owner

dfinke commented Sep 25, 2016

Bummer, the ConditionalText change works like a charm. The ConditionalFormattingIconSet throws an error and no useful info. I need to dig deeper

# Test conditional text and format

$file="C:\Temp\TestChanges.xlsx"

rm $file -ErrorAction Ignore

$data = $(
    New-PSItem 1 2 3 
    New-PSItem 4 5 6 
    #New-PSItem a b c
    New-PSItem 1 2 3 
    New-PSItem 4 5 6 
)

#$ct = New-ConditionalText b
#$data | Export-Excel $file -show -ConditionalText $ct

$cf =  New-ConditionalFormattingIconSet -Range "B:B" -ConditionalFormat ThreeIconSet -IconType Arrows
$data | Export-Excel $file -show -ConditionalFormat $cf

Copy link
Owner

@dfinke dfinke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the ConditionalFormat, I believe it should be $format.Range, that solved the error on my side. Please see if it works for you.

Copy link
Contributor Author

@headsphere headsphere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated from $format.Address to $format.Range

@headsphere
Copy link
Contributor Author

That looks good to me!

@dfinke
Copy link
Owner

dfinke commented Sep 28, 2016

Thanks! Much appreciated.

Question, I don't have PS v3.0 to run this on. How did this manifest itself? Did the module not load? Did it only cause errors when using the conditional sections? Did it just not produce the right results?

Thanks again

@headsphere
Copy link
Contributor Author

You get the error when loading the module. You don't need to even invoke
any functionality, which I found a bit weird. But that just shows the limit
of my Powershell knowledge!

On Wed, Sep 28, 2016 at 1:28 AM, Doug Finke notifications@github.com
wrote:

Thanks! Much appreciated.

Question, I don't have PS v3.0 to run this on. How did this manifest
itself? Did the module not load? Did it only cause errors when using the
conditional sections? Did it just not produce the right results?

Thanks again


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#126 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AIqcKnIjjt6grM05ZNwIZrP_Ilqf1057ks5qubSUgaJpZM4KCvHN
.

Nick Head // +44 791 878 4742 // nick@headsphere.net // www.headsphere.net

@dfinke
Copy link
Owner

dfinke commented Sep 28, 2016

Thanks! Yes, PowerShell parses the target file(s) and determines what are terminating errors, even before execution. Not for everything, and I don't keep those rules in my head. :-)

This is great. This clears some more hurdles for folks who have tried to use this in v3.0

@dfinke dfinke merged commit 4168210 into dfinke:master Sep 28, 2016
@headsphere headsphere deleted the patch-1 branch September 28, 2016 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants